<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" >
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<br><br>
<form class="layui-form" action="" id="form1">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" th:value="${order.name}" name="name" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">WeChat号</label>
        <div class="layui-input-inline">
            <input type="text" th:value="${order.wechat_no}" name="wechat_no" lay-verify="required" autocomplete="off" class="layui-input">
            <input type="hidden" name="order_id" th:value="${order.order_id}">
        </div>
        <label class="layui-form-label">WeChat备注</label>
        <div class="layui-input-inline">
            <input type="text" name="wechat_mark" th:value="${order.wechat_mark}" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">QQ</label>
        <div class="layui-input-inline">
            <input type="text" name="qq_no" th:value="${order.qq_no}"  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">手机</label>
        <div class="layui-input-inline">
            <input type="text" name="tel" th:value="${order.tel}" lay-verify="required" autocomplete="off" class="layui-input">
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">购买课程</label>
        <div class="layui-input-inline">
            <select name="course_name">
                <option value="">选择购买课程</option>
                <option value="2018年Java全套课程">2018年Java全套课程</option>
                <option value="2019年SpringBoot项目">2019年SpringBoot项目</option>
            </select>
            <script>
                //${order.course_name}
                //通过jquery 选中
            </script>
        </div>
        <label class="layui-form-label" >购买价格</label>
        <div class="layui-input-inline">
            <input type="text" name="course_price" th:value="${order.course_price}"  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">购买日期</label>
        <div class="layui-input-inline">
            <input type="text" name="order_date" th:value="${order.order_date}" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="button" onclick="doSave();">提交</button>
        </div>
    </div>
</form>
<script>
    var $,layer;
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;

        $ = layui.jquery;
        layer = layui.layer;
        //日期
        laydate.render({
            elem: '#date'
        });
    }
    );

    function doSave() {
        //获取表单数据
        var formData = $("#form1").serialize();
        //提交表单
        $.post("/courseorder/save",formData,function (msg) {
            if(msg.success == 1){
                layer.alert("修改成功",{yes:function () {
                    parent.layer.closeAll();
                }});
            }else{
                layer.alert("修改失败",{yes:function () {
                    parent.layer.closeAll();
                }});
            }
        });
    }
</script>
    </body>
</html>